#ifndef __IFACE_H__
#define __IFACE_H__
#include <iostream>
#include <string>

#include "inkview.h"

#define CARD_INDEX_CLUBS 	0
#define CARD_INDEX_DIAMONDS 1
#define CARD_INDEX_HEARTS 	2
#define CARD_INDEX_SPADES 	3

#define CARD_INDEX_MISC		4

// NOTE: the order is correct and should be remain
#define CARD_INDEX_ACE 		0
#define CARD_INDEX_KING 	1
#define CARD_INDEX_QUEEN 	2
#define CARD_INDEX_JACKE 	3
#define CARD_INDEX_TEN 		4
#define CARD_INDEX_NINE		5
#define CARD_INDEX_EIGHT 	6
#define CARD_INDEX_SEVEN 	7
#define CARD_INDEX_SIX 		8
#define CARD_INDEX_FIVE		9
#define CARD_INDEX_FOUR 	10
#define CARD_INDEX_THREE 	11
#define CARD_INDEX_TWO 		12

#define CARD_INDEX_COVER	2

#define CARD_WIDTH		68
#define CARD_HEIGHT		105

#define CARD_SPACE		5
#define CARD_CORNER		15

struct pbcRect {
	int x;
	int y;
	int width;
	int height; };

class CLog
{
public:
	
	enum Level { 
		INF,
		ERR,
		WRN } ;

	Level level;
	
	CLog(Level _level ) { this->level = _level; }
	friend std::ostream& operator << ( std::ostream & _os, CLog _log )
	{
		std::string prefix =  "INF";
		switch( _log.level )
		{
			case INF: prefix = "INF"; break;
			case ERR: prefix = "ERR"; break;
			case WRN: prefix = "WRN"; break;
		}
		_os << prefix << ": ";
		
		return _os;
	}
};

extern CLog err;
extern CLog wrn;
extern CLog inf;

class CIface
{
public:
	static bool is_static_init; 
	static ifont *arial8n;
	static ifont *arial12;
	static ifont *arialb12;
	static ifont *cour16;
	static ifont *cour24;
    static ifont *times20;

	static pbcRect* update_areas;
	static int n_update_areas;
	
	static void InitStatic();

	static const ibitmap* card_images[4][14];
	static void InitCardImages();
public:	
	static void CIface::DrawCard( int _suit, int _index, int _x, int _y );
	static void CIface::DrawPlaceHolder( int _x, int _y );
	static void CIface::DrawHand( int _x, int _y );
	static void CIface::DrawBack( int _x, int _y );
	
	static void DrawText( const char* _text, unsigned int _x, unsigned int _y, ifont* _font = NULL );
	
	// static members, interface to those from inkview.h
	static int ScreenWidth() { return ::ScreenWidth(); }
	static int ScreenHeight() { return ::ScreenHeight(); }
	static int GetOrientation() { return ::GetOrientation(); }
	static void SetOrientation(int _orient) { return ::SetOrientation(_orient); }
	static void ClearScreen() { ::ClearScreen(); }
	static void DrawRect( int _x, int _y, int _w, int _h, int _color ) { ::DrawRect( _x, _y, _w, _h, _color ); }
	static void FullUpdate() { ::FullUpdate(); }
	static void FillAreaWithBackground( int _x, int _y, int _width, int _height ) { ::FillArea( _x, _y, _width, _height, WHITE ); }
	static void AddUpdateArea( pbcRect _rect );
	static void UpdateAreas();
	
	CIface();
};


#endif //__IFACE_H__

